# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import QMessageBox, QFileDialog, QInputDialog

from global_data.glabal_data import GlobalData



class DialogUtils(object):
    def __init__(self):
        pass

    @staticmethod
    def checkRes(res):
        if QMessageBox.Ok == res:
            return True
        elif QMessageBox.Yes == res:
            return True
        else:
            return False

    @staticmethod
    def msg(content, title="提示"):
        return QMessageBox.information(GlobalData.SYS_WIN, title, content, QMessageBox.Ok)

    @staticmethod
    def warn(content, title="警告"):
        return QMessageBox.warning(GlobalData.SYS_WIN, title, content, QMessageBox.Ok)

    @staticmethod
    def alert(content, title="严重警告"):
        return QMessageBox.critical(GlobalData.SYS_WIN, title, content, QMessageBox.Ok)

    @staticmethod
    def confirm(content, title="请确认"):
        return QMessageBox.question(GlobalData.SYS_WIN, title, content, QMessageBox.Yes, QMessageBox.No)

    @staticmethod
    def about(content, title="关于"):
        return QMessageBox.about(GlobalData.SYS_WIN, title, content)

    @staticmethod
    def input_int(val=0, min=0, max=9999, step=1, label="输入数字", title="输入对话框"):
        return QInputDialog.getInt(GlobalData.SYS_WIN, title, label, val, min, max, step)

    @staticmethod
    def input_str(val="请输入", label="输入字符串", title="输入对话框"):
        return QInputDialog.getStr(GlobalData.SYS_WIN, title, label, val)

    @staticmethod
    def input_item(items, index, is_select=False, label="列表选项", title="输入对话框"):
        return QInputDialog.getItem(GlobalData.SYS_WIN, title, label, items, index, is_select)

    @staticmethod
    def get_dir(path=GlobalData.WORK_PATH_COMMON, title="选取文件夹"):
        return QFileDialog.getExistingDirectory(GlobalData.SYS_WIN, title, path)

    @staticmethod
    def get_file(path=GlobalData.WORK_PATH_COMMON, ext="All File(*)", title="选取单个文件"):
        return QFileDialog.getOpenFileName(GlobalData.SYS_WIN, title, path, ext)

    @staticmethod
    def get_files(path=GlobalData.WORK_PATH_COMMON, ext="All Files (*);", title="选取多个文件"):
        return QFileDialog.getOpenFileNames(GlobalData.SYS_WIN, title, path, ext)

    @staticmethod
    def save_file(path=GlobalData.WORK_PATH_COMMON, ext="All Files (*);", title="文件保存"):
        return QFileDialog.getSaveFileName(GlobalData.SYS_WIN, title, path, ext)


if __name__ == '__main__':
    print("Python")
